package com.cxb.springboot.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;

/**
 * @Classname ZookeeperWatcherListener
 * @Date 2023/3/28 23:11
 * @Created by Administrator
 * @Description PathChildrenCache：监听指定节点的子节点
 */
@Slf4j
public class MyPathChildrenCacheListener implements PathChildrenCacheListener {

    @Override
    public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) {
        if (event != null && event.getData() != null && event.getType() != null) {
            log.info("接收到PathChildrenCacheListener监听事件，节点：{}，事件类型：{}，数据：{}", event.getData().getPath(), event.getType());
        } else {
            log.info("ZookeeperPathWatcherListener：{}", client);
        }
    }
}